//
//  YDInOptionsModel.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2018/3/5.
//  Copyright © 2018年 LK-IOS. All rights reserved.
//

#import "YDInOptionsModel.h"

@implementation YDInOptionsModel

+ (NSDictionary *)mj_replacedKeyFromPropertyName
{
    return @{
             @"Id" : @"id"
             };
}

//名义本金
-(NSString *)pzNominalAmount
{
    if (!self.nominalAmount.length || self.nominalAmount.floatValue <=0) {
        return @"---";
    }else{
        NSString *string = [self.nominalAmount pz_stringNumberByDividingBy:@"10000"];
        
        
        return [NSString stringWithFormat:@"%@万元" , string];
    }
}

//买入价格
-(NSString *)pzBuyPrice
{
    if (!self.buyingPrice.length || self.buyingPrice.floatValue <= 0) {
        return @"---";
    }else{
        
        return [NSString stringWithFormat:@"%@元" , [self.buyingPrice pz_stringNumberByMultiplyingBy:@"1"]];
    }
}

-(NSString *)pzBuyWay
{
    return @"市价买入";
}

//权利金
-(NSString *)pzRightMoney
{
    if ((!self.rightMoneyRatio.length || self.rightMoneyRatio.floatValue <= 0) || !self.nominalAmount.length || self.nominalAmount.floatValue <= 0) {
        return @"---";
    }else{
        NSString *string = [self.rightMoneyRatio pz_stringNumberByMultiplyingBy:self.nominalAmount];
        
        return [NSString stringWithFormat:@"%@元" , [NSString countNumAndChangeformat:string]];
    }
    
}

//时间
-(NSString *)pzYear
{
    if ([self.state isEqualToString:@"WAITCONFIRMED"]) {//待确认
        
        NSDateFormatter *formate = [[NSDateFormatter alloc] init];
        [formate setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSDate *date = [formate dateFromString:self.applyTime];
        NSDateFormatter *formate1 = [[NSDateFormatter alloc] init];
        [formate1 setDateFormat:@"yyyy.MM.dd"];
        return [formate1 stringFromDate:date];
        
    }else{
        if (self.rightTime.length) {
            
            NSDateFormatter *formate = [[NSDateFormatter alloc] init];
            [formate setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
            NSDate *date = [formate dateFromString:self.rightTime];
            NSDateFormatter *formate1 = [[NSDateFormatter alloc] init];
            [formate1 setDateFormat:@"yyyy.MM.dd"];
            return [formate1 stringFromDate:date];
            
        }else{
            NSDateFormatter *formate = [[NSDateFormatter alloc] init];
            [formate setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
            NSDate *date = [formate dateFromString:self.buyingTime];
            NSDateFormatter *formate1 = [[NSDateFormatter alloc] init];
            [formate1 setDateFormat:@"yyyy.MM.dd"];
            return [formate1 stringFromDate:date];
        }
    }
}

-(NSString *)pzHour
{
    if ([self.state isEqualToString:@"WAITCONFIRMED"]) {//待确认
        
        NSDateFormatter *formate = [[NSDateFormatter alloc] init];
        [formate setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSDate *date = [formate dateFromString:self.applyTime];
        NSDateFormatter *formate1 = [[NSDateFormatter alloc] init];
        [formate1 setDateFormat:@"HH:mm:ss"];
        return [formate1 stringFromDate:date];
        
    }else{
        if (self.rightTime.length) {
            
            NSDateFormatter *formate = [[NSDateFormatter alloc] init];
            [formate setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
            NSDate *date = [formate dateFromString:self.rightTime];
            NSDateFormatter *formate1 = [[NSDateFormatter alloc] init];
            [formate1 setDateFormat:@"HH:mm:ss"];
            return [formate1 stringFromDate:date];
            
        }else{
            NSDateFormatter *formate = [[NSDateFormatter alloc] init];
            [formate setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
            NSDate *date = [formate dateFromString:self.buyingTime];
            NSDateFormatter *formate1 = [[NSDateFormatter alloc] init];
            [formate1 setDateFormat:@"HH:mm:ss"];
            return [formate1 stringFromDate:date];
        }
    }
}

-(BOOL)isCanSale
{
    if ([self.state isEqualToString:@"TURNOVER"]) {
        return YES;
    }else{
        return NO;
    }
}

-(NSString *)chengJiaoTime
{
    if (!self.buyingTime.length) {
        return @"---";
    }else{
        NSDateFormatter *formate = [[NSDateFormatter alloc] init];
        [formate setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSDate *date = [formate dateFromString:self.buyingTime];
        NSDateFormatter *formate1 = [[NSDateFormatter alloc] init];
        [formate1 setDateFormat:@"yyyy.MM.dd"];
        return [formate1 stringFromDate:date];
    }
}
-(NSString *)pzExpireTime
{
    if (!self.expireTime.length) {
        return @"---";
    }else{
        NSDateFormatter *formate = [[NSDateFormatter alloc] init];
        [formate setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSDate *date = [formate dateFromString:self.expireTime];
        NSDateFormatter *formate1 = [[NSDateFormatter alloc] init];
        [formate1 setDateFormat:@"yyyy.MM.dd"];
        return [formate1 stringFromDate:date];
    }
}

-(NSString *)pzLastPrice
{
    if (!self.lastPrice.length || self.lastPrice.floatValue <= 0) {
        return @"---";
    }else{
        NSString *string = [self.lastPrice pz_stringNumberByMultiplyingBy:@"1"];
        return [NSString stringWithFormat:@"%@元" , string];
    }
}

//浮动盈亏
-(NSString *)pzProfit
{
    if (!self.profit.length) {
        return @"---";
    }else{
        if ([self.profit floatValue] < 0) {
            //提出负号
            NSString *string = [self.profit stringByReplacingOccurrencesOfString:@"-" withString:@""];
            return [NSString stringWithFormat:@"-%@" , [NSString countNumAndChangeformat:string]];
        }else if ([self.profit floatValue] == 0)
            return self.profit;
        else{
            return [NSString stringWithFormat:@"+%@" , [NSString countNumAndChangeformat:self.profit]];
        }
        
    }
}





@end
